package com.example.emos.wx.config;

import com.rabbitmq.client.ConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MQ配置类
 */
@Configuration
public class RabbitMQConfig {

    @Value("${rabbitmq.host}")
    private String rabbitMqHost;

    @Value("${rabbitmq.port}")
    private int rabbitMqPort;

    /**
     * 设置消息为同步收发
     * @return MQ消息工厂
     */
    @Bean
    public ConnectionFactory getFactory() {
        ConnectionFactory factory = new ConnectionFactory();
        /*Linux主机的IP地址*/
        factory.setHost(rabbitMqHost);
        //RabbitMQ端口号
        factory.setPort(rabbitMqPort);
        return factory;
    }
}

